package my.interview;

import java.util.Scanner;

/**
 * @DESCRIPTION:
 * @USER: shg
 * @DATE: 2022/12/27 23:17
 */
public class Hj33_ {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNext()) {
            String next = scanner.next();
            if (next.contains(".")) {
                System.out.println(ip2num(next));
            } else {
                System.out.println(num2ip(next));
            }
        }
    }

    private static String num2ip(String next) {
        long l = Long.parseLong(next);
        String string = Long.toBinaryString(l);
        while (string.length()<32){
            string  = "0"+string;
        }
        String[] ans = new String[4];
        for(int i=0;i<4;i++){
            String substring = string.substring(8 * i, 8 * i + 8);
            String string1 = Integer.toString(Integer.parseInt(substring, 2));
            ans[i] = string1;
        }
        return String.join(".", ans);
    }

    private static Long ip2num(String next) {
        String[] split = next.split("\\.");
        StringBuilder stringBuilder = new StringBuilder();
        for (int i = 0; i < 4; i++) {
            String string = Integer.toBinaryString(Integer.parseInt(split[i]));
            while (string.length()<8){
                string = "0"+string;
            }
            stringBuilder.append(string);
        }
        return Long.parseLong(stringBuilder.toString(),2);
    }
}
